unit Download;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Mask;

type
  TFormDownload = class(TForm)
    GroupBox1: TGroupBox;
    CheckBox1: TCheckBox;
    Edit1: TEdit;
    GroupBox2: TGroupBox;
    CheckBox2: TCheckBox;
    Edit2: TEdit;
    GroupBox3: TGroupBox;
    Edit3: TEdit;
    CheckBox3: TCheckBox;
    BitBtn1: TBitBtn;
    GroupBox4: TGroupBox;
    RB_Total: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    Label1: TLabel;
    MaskEdit1: TMaskEdit;
    Label2: TLabel;
    MaskEdit2: TMaskEdit;
    procedure BitBtn1Click(Sender: TObject);
    procedure RB_TotalClick(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure RadioButton3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormDownload: TFormDownload;
  tipo:string = '0';

implementation

uses principal, funcoesapoio, declaracoes;

{$R *.dfm}

procedure TFormDownload.BitBtn1Click(Sender: TObject);
begin
        if checkbox1.checked then begin
                FormPrincipal.Statusbar1.Panels[0].Text:='Download Software Basico'; WaitProcess;
                Resposta := ECF_DownloadSB(Edit1.Text);
                FormPrincipal.Memo1.Lines.Add('Download Software Basico:'+inttostr(Resposta));
                VerificaRetornoFuncao(Resposta);

        end;
        if checkbox2.checked then begin
                FormPrincipal.Statusbar1.Panels[0].Text:='Download Memoria de Fita-Detalhe'; WaitProcess;
                Resposta := ECF_DownloadMFD(Edit2.Text,tipo,Maskedit1.Text, Maskedit2.Text,'0');
                FormPrincipal.Memo1.Lines.Add('Download Memoria de Fita-Detalhe:'+inttostr(Resposta));
                VerificaRetornoFuncao(Resposta);
        end;
        if checkbox3.checked then begin
                FormPrincipal.Statusbar1.Panels[0].Text:='Download Memoria Fiscal'; WaitProcess;
                Resposta := ECF_DownloadMF(Edit3.Text);
                FormPrincipal.Memo1.Lines.Add('Download Memoria Fiscal:'+inttostr(Resposta));
                VerificaRetornoFuncao(Resposta);

        end;

end;

procedure TFormDownload.RB_TotalClick(Sender: TObject);
begin
        MaskEdit1.Enabled:=False;
        MaskEdit2.Enabled:=False;
        MaskEdit1.Text:='';
        MaskEdit2.Text:='';
        tipo:='0';
end;

procedure TFormDownload.RadioButton2Click(Sender: TObject);
begin
        MaskEdit1.EditMask:='!99/99/00;1;_';
        MaskEdit2.EditMask:='!99/99/00;1;_';
        MaskEdit1.Text:=FormatDateTime('dd/mm/yy',date);
        MaskEdit2.Text:=FormatDateTime('dd/mm/yy',date);
        MaskEdit1.Enabled:=True;
        MaskEdit2.Enabled:=True;
        tipo:='1';
end;

procedure TFormDownload.RadioButton3Click(Sender: TObject);
begin
        MaskEdit1.Enabled:=True;
        MaskEdit2.Enabled:=True;
        MaskEdit1.EditMask:='!000000;1;_';
        MaskEdit2.EditMask:='!000000;1;_';
        MaskEdit1.Text:='000001';
        MaskEdit2.Text:='999999';

        tipo:='2';
end;

end.
